#include <iostream>
#include <string>
#include <map>
using namespace std;
int main() 
{
    string S;
    cin >> S;
    long long N = S.length();
    long long totalSwaps = N * (N - 1) / 2;
    map<char, long long> charCounts;
    for (int i=0;i<S.size();i++) 
	{
        charCounts[S[i]]++;
    }
    int flag=1;
    for (map<char, long long>::iterator it=charCounts.begin();it!=charCounts.end();it++) 
	{
        long long count = it->second;
        if (count > 1) 
		{
            totalSwaps -= count * (count - 1) / 2;
        }
        if(count>=2)
        {
        	flag=0;
		}
    }
    if(flag==1)
    {
    	cout << totalSwaps << endl;
	}
    else if(flag==0)
    {
    	cout << totalSwaps+1 << endl;
	}
    return 0;
}
